<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>公布运价维护</title>
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/ligerui-icons.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/show.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/core/base.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link rev="stylesheet" media="all"
	href="<%=request.getContextPath()%>/fare/css/form_style.css"
	type="text/css" rel="stylesheet">
<link
	href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
	<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
	
	<!-- 圆角文本框 -->
	<link href="<%=request.getContextPath()%>/fare/css/htc/htc.css"
		rel="stylesheet" type="text/css" />
		
	<style type="text/css">
		.t1{
			margin: 4px;
			padding:3px;
		
		}
	
	</style>
<script type="text/javascript">
	var freightGrid;
	function itemclick(item) {
		var manager = $("#maingrid").ligerGetGridManager(); 
		var row = manager.getSelectedRow(); 
       if(item.text == '增加'){
        	$("#flag").val("save");
        	showDialog();
        } 
       else if(item.text == '修改'){
    	   if(row == null){
           	alert("请先选择一条数据!");
           	return ;
           }

    	   $("#dataId").val( row.id);
    	   $("#flag").val("update");
    	   $("#standardPrice").val(row.standardPrice);
    	   $("#fromCityName").val(row.fromCityName);
    	   $("#toCityName").val(row.toCityName);
    	   $("#tourist").val(row.tourist);
    	   $("#official").val(row.official);
    	   $("#bussiness").val(row.bussiness);
    	   showDialog();
       }else{
    	   if(row == null){
              	alert("请先选择一条数据!");
              	return ;
              }
    	   $.ligerDialog.confirm('确定删除?', function (yes) {	
    		   $("#dataId").val(row.id);
        	   $("#flag").val("delete");
    		   $("form:first").submit();
    	   });
       }
	}
	
	function showDialog(){
		
		
		/* $("#flag").attr("value", "add");
		$("#id").attr("value", "");
		$("#fromSelect").attr("value", "");
		$("#destSelect").attr("value", "");
		$("#voyage").attr("value", "");
		$("#departTime").attr("value", "");
		$("#fightNo").attr("value", "");
		showWindow("添加记录"); */
		
		 $.ligerDialog.open({
			title : '编辑窗口',
			target : $("#formcontainer"),
			isResize: true,
			width : 530,
			height :400
		}); 
	}
	
	function checkForm(){
		var fromCityName = $("#fromCityName").val();
		var toCityName = $("#toCityName").val();
		var tourist = $("#tourist").val();
		var official = $("#official").val();
		var bussiness = $("#bussiness").val();
		if(fromCityName==''||toCityName==''||tourist==''||official==''||bussiness==""){
			alert("请填写完整数据!");
			return false;
		}
		return true;
	}
	
	$(function() {
		$('#depCity').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
			});
		$('#arrCity').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
			});
		$('#fromCityName').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
		});
		$('#toCityName').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
		});
		$.ajax({
					url : "freightPublishAction!getData.action",
					async : false,
					dataType : "json",
					success : function(data) {
						freightGrid = $("#maingrid")
								.ligerGrid(
										{
											height : '100%',
											columns : [ {
												display : '出发地',
												/* name : 'fromCityName', */
												align : 'center',
												isSort:true,
												minWidth : 120,
												render:function(row){
													return row.fromCityName+'('+row.fromCity+')';	
												}
											},{
												display : '目的地',
												name : 'toCityName',
												minWidth : 120,
												render:function(row){
													return row.toCityName+'('+row.toCity+')';	
												}
											},{
												display:'标准运价',
												name:'standardPrice',
												minWidth : 120
											},{
												display:'里程数',
												name:'mileage',
												minWidth : 120
											}],
											data : data,
											pageSize : 20,
											rownumbers : true,
											toolbar : {
												items : [
														{
															text : '增加',
															click : itemclick,
															icon : 'add'
														},
														{
															line : true
														},
														{
															text : '修改',
															click : itemclick,
															icon : 'modify'
														},
														{
															line : true
														},
														{
															text : '删除',
															click : itemclick,
															img : '<%=request.getContextPath()%>/fare/js/ligerUI/skins/icons/delete.gif'
														} ]
											}
										});
						$("#pageloading").hide();
					}

				});

	});

	function deleteRow() {
		g.deleteSelectedRow();
	}
	
	function checkLine(){
		var fromCtity = $("#depCity").val();
		var toCity = $("#arrCity").val();
		if(fromCtity == '中文/拼音'){
			fromCtity="";
		}
		if(toCity == '中文/拼音'){
			toCity ="";
		}
		var data = {"fromCtity":fromCtity,"toCity":toCity};
		var url = "freightPublishAction!findByCity.action";
		
		//alert(fromCtity + toCity);
		$.ajax({
			url : url,
			data: data,
			type : "POST",
			async : false,
			dataType : "json",
			success : function(data) {
				freightGrid = $("#maingrid")
						.ligerGrid(
								{
									height : '100%',
									columns : [/*  {
										display : 'id',
										name : 'id',
										align : 'left',
										width : 100,
										minWidth : 60
									}, */ {
										display : '出发地',
										/* name : 'fromCityName', */
										align : 'left',
										width : 100,
										minWidth : 60,
										isSort:true,
										render:function(row){
											return row.fromCityName+'('+row.fromCity+')';	
										}
									},{
										display : '目的地',
										name : 'toCityName',
										minWidth : 120,
										render:function(row){
											return row.toCityName+'('+row.toCity+')';	
										}
									},{
										display:'标准运价',
										name:'standardPrice',
										minWidth : 120
									},{
										display:'里程数',
										name:'mileage',
										minWidth : 120
									} /* , {
										display : '经济舱价格',
										name : 'tourist',
										minWidth : 140
									}, {
										display : '公务舱价格',
										name : 'official'
									}, {
										display : '商务舱价格',
										name : 'bussiness'
									}  */ ],
									data : data,
									pageSize : 30,
									rownumbers : true,
									toolbar : {
										items : [
												{
													text : '增加',
													click : itemclick,
													icon : 'add'
												},
												{
													line : true
												},
												{
													text : '修改',
													click : itemclick,
													icon : 'modify'
												},
												{
													line : true
												},
												{
													text : '删除',
													click : itemclick,
													img : '<%=request.getContextPath()%>/fare/js/ligerUI/skins/icons/delete.gif'
												} ]
									}
								});
				$("#pageloading").hide();
			}

		});
	}
</script>

</head>
<body style="overflow-x: hidden; padding: 2px;">
	<div class="form_table_tltle">查询条件</div>
	<div>
			<table cellSpacing=0 cellPadding=0 width="400px" border=0 >
				<TR>
					<TD width="80px" height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
					<TD width="240px">
						<!-- <input type="text" style="width: 100px" name="vo.fromCity"
						id="depCity" > <span>至</span>
							<input type="text" style="width: 100px" name="vo.toCity"
							id="arrCity" > -->
							<jsp:include page="/inc/flightSelect.jsp">
	    <jsp:param value="" name="fromCity"/>
	    <jsp:param value="" name="fromCityCode"/>
	    <jsp:param value="" name="toCity"/>
	    <jsp:param value="" name="toCityCode"/>
 </jsp:include>
					 </TD>
							
					<TD width="10px" class="left" style="text-align: left"></TD>
					<TD width="80px"><input type="button" value="查询"  style="width: 60px" onclick="checkLine();" /></TD>
				</TR>
			</TABLE>
	</div>
	<div class="l-loading" style="display: block" id="pageloading"></div>
	<div class="l-clear"></div>
	
	<div id="maingrid"></div>

		<div id="formcontainer" style="display:none; width: 300;">
			<form id="form1" action="freightPublishAction!dealSomething.action" onsubmit="return checkForm();">
				<input id="dataId" name="vo.id" type="text" style="display: none;" />
				<input id="flag" name="flag" type="text" style="display: none;" />
				<table style="padding: 2px;" cellspacing="10" align="center">
					<tr width="10%" height="26" class="t1">
						<td class="t1">出发地:</td>
						<td class="t1"><input id="fromCityName" name="vo.fromCityName" type="text" /></td>
					</tr>
					<tr width="10%" height="26" class="t1">
						<td class="t1">目的地:</td>
						<td class="t1"><input id="toCityName" name="vo.toCityName" type="text" /></td>
					</tr>
					<tr width="10%" height="26" class="t1">
						<td class="t1">标准运价:</td>
						<td class="t1"><input id="standardPrice" name="vo.standardPrice" type="text" /></td>
					</tr>
					<!-- <tr width="10%" height="26" class="t1">
						<td class="t1">经济舱价格:</td>
						<td class="t1"><input id="tourist" name="vo.tourist" type="text" /></td>
					</tr>
					<tr width="10%" height="26" class="t1">
						<td class="t1">公务舱价格:</td>
						<td class="t1"><input id="official" name="vo.official" type="text" /></td>
					</tr>
					<tr width="10%" height="26" class="t1">
						<td class="t1">商务舱价格:</td>
						<td class="t1"><input id="bussiness" name="vo.bussiness" type="text" /></td>
					</tr> -->
					<tr width="10%" height="26" class="t1">
						<td align="right" class="t1" colspan="2"><input type="submit" value="确定"  style="width: 60px" /></td>
					</tr>

				</table>

			</form>
		</div>

</body>
</html>